package com.panopset.flywheel.gui;

import java.awt.GridLayout;

import javax.swing.JPanel;

import com.panopset.app.panopset.Application;
import com.panopset.gui.TPanel;

/**
 * Graphical User Interface (GUI) front-end to Flywheel.
 * applicationInterface.getFile()
 *
 * @author Karl Dinwiddie
 *
 */
public final class Gui extends Application {

    /**
     * Main application panel.
     */
    private FlywheelMainApplicationPanel flywheelMainApplicationPanel;

    /**
     * @return Main application panel.
     */
    public FlywheelMainApplicationPanel getFlywheelMainApplicationPanel() {
        if (flywheelMainApplicationPanel == null) {
            flywheelMainApplicationPanel = new FlywheelMainApplicationPanel();
        }
        return flywheelMainApplicationPanel;
    }

    @Override
    protected JPanel createMainPanel() {
        TPanel rtn = new TPanel.Builder().layout(new GridLayout(1, 1))
                .construct();
        rtn.add(getFlywheelMainApplicationPanel()
                            .getPanel());
        return rtn;
    }

    @Override
    protected void load() {
        super.load();
        getFlywheelMainApplicationPanel().load();
    }

    @Override
    public void aboutToQuit() {
        getFlywheelMainApplicationPanel().quit();
    }

    @Override
    public String createApplicationName() {
        return APP_NAME;
    }

    /**
     * Application name.
     */
    public static final String APP_NAME = "Flywheel";
}
